<?php
/**
 * @file index.php
 * @package 
 * @subpackage 
 * @version $id: 0.1 UTF-8 2009-2-25 下午09:14:17 $
 * @author LD King (mifunny.info)
 * @copyright Copyright (c) 2007 - 2008 MiFunny China Inc. (http://mifunny.info)
 */
?>

<?php 
try {
	$db = new PDO("sqlite:SQLTrackback.db", null, null, array(PDO::ATTR_PERSISTENT => true));
}catch (PDOException $ex){
	die("[Error]: ".$ex->getMessage().'<br />\n');
}

// Useless but carefully is better, set encoding.
// Sqlite always use utf-8 internaly, UTF-8 is also it's default value.
$db->query('PRAGMA encoding = "UTF-8"');
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

$url = "http://www.jlcauvin.com/wordpress/wp-trackback.php?p=638";
$url2 = "http://www.pydkpodcast.com/wp-trackback.php?p=71";
$follow = 0;

$sqlInsert = "INSERT INTO tb VALUES(null, \"".$url."\", ".$follow.", julianday('now') )";
$db->exec($sqlInsert);

$sqlSelect = "SELECT id, url, follow, date FROM tb";
foreach ($db->query($sqlSelect) as $row) {
	echo $row['id']." - ".$row['url']." - ".$row['follow']." - ".$row[date]."<br />";
}

echo "<br />Results:<br />";
$sqlSelect2 = "SELECT id, url, follow, date FROM tb WHERE url = \"".$url2."\"";
$result = $db->query($sqlSelect2);
echo "There were ".$result->columnCount()." product fields returned.<br />";
foreach ($result as $row) {
	echo $row['id']." - ".$row['url']." - ".$row['follow']." - ".$row[date]."<br />";
}



?>